package com.itic.mall.system.productsku.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.mall.system.productproperty.persistence.dao.ProductPropertyDao;
import com.itic.mall.system.productproperty.persistence.model.ProductProperty;
import com.itic.mall.system.productpropertyvalue.persistence.dao.ProductPropertyValueDao;
import com.itic.mall.system.productpropertyvalue.persistence.model.ProductPropertyValue;
import com.itic.mall.system.productsku.persistence.dao.ProductSkuDao;
import com.itic.mall.system.productsku.persistence.model.ProductSku;
import com.itic.mall.system.productsku.persistence.model.ProductSkuExample;


@Service
@Transactional
public class ProductSkuService
     extends CrudService<ProductSkuDao,ProductSku,ProductSkuExample> {
    @Autowired
    private ProductSkuDao productSkuDao;
    @Autowired
    private ProductPropertyDao productPropertyDao;
    @Autowired
    private ProductPropertyValueDao productPropertyValueDao;

	public String getNameByProductPropertys(String productPropertys) {
		String result = "";
		if( StringHelper.isNotBlank(productPropertys) ){
			String[] split = productPropertys.split(",");
			for( int i=0;i<split.length;i++ ){
				if( !split[i].equals("")|| !(null == split[i]) ){
					String[] split2 = split[i].split(":");
					ProductProperty proName = productPropertyDao.selectByPrimaryKey(split2[0]);
					ProductPropertyValue proValueName = productPropertyValueDao.selectByPrimaryKey(split2[1]);
					result = proName.getName()+":"+proValueName.getPropertyValue();
				}
				
			}
		}
		return result;
	}


}